<template>
  <p-config-provider :locale="locale" :transform-cell-text="transformCellText">
    <div id="app" :class="{ 'iframe-open': isIframeOpen }">
      <router-view />
    </div>
  </p-config-provider>
</template>

<script>
import { mapGetters } from 'vuex';
import { isIframeOpen } from '@/utils';
import { getLocalUserInfo } from '@/api/public.js';

export default {
  name: 'App',
  data() {
    return {
      isIframeOpen,
    };
  },
  computed: {
    ...mapGetters(['language']),

    locale() {
      return require(`poros/ui/lib/locale-provider/${this.language}`).default;
    },
  },
  created() {
    this.$store.dispatch('getLanguageCache');
    this.$store.dispatch('getOrganizationTree', 'ltcsmsizebu');
    this.$store.dispatch('getAllDicList');

    if (process.env.NODE_ENV === 'development') {
      this.getLocalUserInfo();
    }
  },
  methods: {
    async getLocalUserInfo() {
      const result = await getLocalUserInfo();
      const data = result?.data?.data;
      localStorage.setItem('poros-current-user', data);
    },
    transformCellText({ text }) {
      if (text === 0) return 0;
      return text || '-';
    },
  },
};
</script>

<style lang="less" scoped>
#app {
  width: 100%;
  height: 100%;
  display: flex;

  &.iframe-open {
    padding: 0;
  }
}

/deep/ .poros-router-tabs__main {
  padding: 0 !important;
  border: none !important;
  background: #f7f7f8 !important;
}
</style>
